<template>
  <div>
    <h2>订单列表</h2>
    <table>
      <thead>
        <tr>
          <th>订单ID</th>
          <th>用户ID</th>
          <th>订单日期</th>
          <th>总价</th>
          <th>状态</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="order in orders" :key="order.orderId">
          <td>{{ order.orderId }}</td>
          <td>{{ order.userId }}</td>
          <td>{{ order.orderDate }}</td>
          <td>{{ order.totalPrice }}</td>
          <td>{{ order.status }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name: 'OrderList',
  data() {
    return {
      orders: []
    };
  },
  mounted() {
    request.get('/orders')
      .then(res => this.orders = res.data)
      .catch(err => console.error(err));
  }
}
</script>
